Merge branch 'master' of git://repo.or.cz/mqlkit
[mqlkit.git] / indicators / Fisher Transform over Stochastic Oscillator.mq4
blobbb8db9aba713f4acca1264d2281d5c3b8a19ec15
1 //+------------------------------------------------------------------+\r
2 //|                                               RAVI FX Fisher.mq4 |\r
3 //|                         Copyright © 2005, Luis Guilherme Damiani |\r
4 //|                                      http://www.damianifx.com.br |\r
5 //+------------------------------------------------------------------+\r
6 #property copyright "Copyright © 2005, Luis Guilherme Damiani"\r
7 #property link      "http://www.damianifx.com.br"\r
8 \r
9 #property indicator_separate_window\r
10 #property indicator_buffers 3\r
11 #property indicator_color1 Lime\r
12 #property indicator_color2 Red\r
13 #property indicator_color3 Yellow\r
15 //---- input parameters\r
16 extern int       lenth=10;\r
17 extern int       maxbars=2000;\r
20 //---- buffers\r
21 double FishBuffer[];\r
22 double SignalBuffer[];\r
23 double AuxBuffer[];\r
25 //+------------------------------------------------------------------+\r
26 //| Custom indicator initialization function                         |\r
27 //+------------------------------------------------------------------+\r
28 int init()\r
29   {\r
30 //---- indicators\r
31    SetIndexStyle(0,DRAW_LINE);\r
32    SetIndexBuffer(0,FishBuffer);\r
33    SetIndexStyle(1,DRAW_LINE);\r
34    SetIndexBuffer(1,SignalBuffer);\r
35    SetIndexStyle(2,DRAW_LINE);\r
36    SetIndexBuffer(2,AuxBuffer);\r
37    SetLevelValue(0,0.8);\r
38    SetLevelValue(1,-0.8);\r
39    ArrayInitialize(FishBuffer,0);\r
40    ArrayInitialize(SignalBuffer,0);\r
41    ArrayInitialize(AuxBuffer,0);\r
42 //----\r
43    return(0);\r
44   }\r
45 //+------------------------------------------------------------------+\r
46 //| Custor indicator deinitialization function                       |\r
47 //+------------------------------------------------------------------+\r
48 int deinit()\r
49   {\r
50 //---- \r
51    \r
52 //----\r
53    return(0);\r
54   }\r
55 //+------------------------------------------------------------------+\r
56 //| Custom indicator iteration function                              |\r
57 //+------------------------------------------------------------------+\r
59 int start()\r
60   {\r
61       int    counted_bars=IndicatorCounted();\r
62       Comment(Bars,"  ", counted_bars);\r
63       //double Normalized=0;\r
64       //double Fish=0;\r
65       //---- check for possible errors\r
66       if(counted_bars<0) return(-1);\r
67       int limit=Bars-counted_bars;\r
68       if(limit>maxbars)limit=maxbars;      \r
69       if (limit>Bars-lenth-1)limit=Bars-lenth-1;   \r
70       //---- \r
71       for (int shift = limit; shift>=0;shift--)\r
72       {\r
73               AuxBuffer[shift]=0.5*(iStochastic(NULL,0,lenth,2,1,MODE_SMA,0,MODE_MAIN,shift)/100-0.5)*2+0.5*AuxBuffer[shift+1];  \r
74               \r
75               FishBuffer[shift]= 0.25* MathLog((1+AuxBuffer[shift])/(1-AuxBuffer[shift]))+0.5*FishBuffer[shift+1];       \r
76          SignalBuffer[shift]=FishBuffer[shift+1];\r
77          \r
78        }\r
79    \r
80 //----\r
81    return(0);\r
82   }\r
83 //+------------------------------------------------------------------+